<template>
  <div class="loninview">
    <el-card class="login-form-layout">
      <el-form
        autocomplete="on"
        :model="loginForm"
        :rules="loginRules"
        ref="loginForm"
        label-position="left"
      >
        <div style="text-align: center">
          <!-- <img src="../../assets/images/logoBlue.png" style="color: black" alt /> -->
          <!-- <svg-icon icon-class="login-mall" style="width: 56px;height: 56px;color: #409EFF"></svg-icon> -->
        </div>
        <h2 class="login-title color-main">昌乐城乡物流后台管理系统</h2>
        <el-form-item prop="username">
          <el-input
            name="phone"
            type="text"
            v-model="loginForm.phone"
            autocomplete="on"
            placeholder="请输入登陆手机号"
          >
          </el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input
            name="password"
            type="password"
            v-model="loginForm.password"
            autocomplete="on"
            placeholder="请输入密码"
          >
          </el-input>
        </el-form-item>
        <el-form-item style="margin-bottom: 60px">
          <el-button
            style="width: 100%"
            type="primary"
            :loading="loading"
            @click.native.prevent="goLogin"
          >登录</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <!-- <img :src="login_center_bg" class="login-center-layout" /> -->
  </div>
</template>

<script>

export default {
  name: "login",
  data() {
    return {
      loginForm: {
        phone: "",
        password: ""
      },
      loginRules: {
        phone: [
          { required: true, message: "请输入用户手机号", trigger: "blur" }
        ],
        password: [{ required: true, message: "请输入密码",trigger: "blur", }]
      },
      loading: false,
    };
  },
  methods: {
    goLogin(){
      this.$refs.loginForm.validate(valid => {
        if (valid) {
          this.loading = true;
          this.$store
            .dispatch("Login", this.loginForm)
            .then(() => {
              this.loading = false;
              this.$router.push({ path: "/" });
            })
            .catch(() => {
              this.loading = false;
            });
        } else {
          return false;
        }
      });
    }
  }
};
</script>

<style scoped>
.loninview{
  position: fixed;
  height: 100%;
  width: 100%;
  background: url('');
  background-size: 100% 100%;
}

.login-form-layout {
  position: absolute;
  left: 0;
  right: 0;
  width: 360px;
  margin: 15% auto;
  border-top: 10px solid #409eff;
}

.login-title {
  text-align: center;
  margin: 20px 0;
}



.login-center-layout {
  background: #409eff;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  margin-top: 200px;
}
</style>
